#include<stdio.h>
#include "LinkQueue.h"

#define true 1
#define false 0


int LQInit(struct LinkQueue *lq)
{
    InitDLlist(&lq->queue);
    return 0;
}

void LQFree(struct LinkQueue *lq)
{
    FreeDLlist(&lq->queue);
}

void LQPush(struct LinkQueue *lq,ElementType element)
{
    InsertTail(&lq->queue,element);
}

int LQIsEmpty(struct LinkQueue *lq)
{
    if(lq->queue.len == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

ElementType* LQPop(struct LinkQueue *lq)
{
    if(LQIsEmpty(lq) == true)
    {
        printf("队列为空\n");
        return NULL;
    }
    lq->FrontElement = lq->queue.head->data;
    RemoveByIndex(&lq->queue,0);
    return &lq->FrontElement;
}

struct Node *LQGetFront(struct LinkQueue *lq)
{
    return lq->queue.head;
}

int GetQueueLen(LQueue *lq)
{
    return lq->queue.len;
}
